package main

import "fmt"

var pow = []int{1, 2, 4, 8, 16, 32, 64, 128}

func main() {
	//range格式循环，遍历简单的数组
	for i, v := range pow {
		fmt.Printf("2**%d = %d\n", i, v)
	}

	println("========================")
	rangeDemo()
}

func rangeDemo() {
	map1 := make(map[int]float32)
	map1[1] = 1.0
	map1[2] = 2.0
	map1[3] = 3.0
	map1[4] = 4.0

	//读取key和value
	for key, value := range map1 {
		fmt.Printf("key is: %d - value is: %f\n", key, value)
	}

	//读取key
	for key := range map1 {
		fmt.Printf("key is: %d\n", key)
	}

	//读取value
	for _, value := range map1 {
		fmt.Printf("value is: %f\n", value)
	}
}
